package me.yushuai.wukong.base.entity;

import lombok.*;
import me.yushuai.wukong.common.domain.AbstractAudit;
import org.hibernate.Hibernate;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * 系统代码明细
 *
 * @author zhoushuai@189.cn
 * @since 2022-09-13
 */
@Getter
@Setter
@Entity
@ToString
@Table(name = "BAS_CONF", indexes = {@Index(columnList = "CONF_ID,GROUP_ID")})
public class Conf extends AbstractAudit implements Serializable {
    /**
     * 配置项编号
     */
    @Id
    @Column(name = "CONF_ID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 配置项代码
     */
    @Column(name = "CONF_BIZ_ID", nullable = false)
    private String bizId;

    /**
     * 系统配置ID
     */
    @Column(name = "GROUP_ID", updatable = false, nullable = false)
    private Long groupId;

    /**
     * 中文描述
     */
    @Column(name = "CONF_NAME_CH")
    private String confNameC;

    /**
     * 英文描述
     */
    @Column(name = "CONF_NAME_EN")
    private String confNameE;


    @Column(name = "CONF_VALUE1")
    private String value1;

    @Column(name = "CONF_VALUE2")
    private String value2;

    /**
     * 自定义1
     */
    @Column(name = "UDF1")
    private String udf1;

    /**
     * 自定义2
     */
    @Column(name = "UDF2")
    private String udf2;

    /**
     * 自定义3
     */
    @Column(name = "UDF3")
    private String udf3;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
            return false;
        }
        Conf conf = (Conf) o;
        return id != null && Objects.equals(id, conf.id);
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}